home *** CD-ROM | disk | FTP | other *** search
/ The Utilities Experience / The Utilities Experience - Volume 1.iso / software / misc / a-d / 3.0iupdate / macros.lha / RotateAboutPoint.rexx < prev    next >
OS/2 REXX Batch file  |  1995-11-27  |  6KB  |  179 lines

  1. /* $VER: RotateAboutPoint.rexx 1.0a (27.11.95)
  2.    Copyright 1995 Soft-Logik Publishing Corporation
  3.    May not be distributed without Soft-Logik Publishing Corporation's express written permission */
  4.  
  5. OPTIONS RESULTS
  6. TRACE OFF
  7.  
  8. ADDRESS 'PAGESTREAM'
  9.  
  10. /* Get the current rotation values and strip off the degree and measurement symbols */
  11. getobject type objtype rotation rstem about astem
  12.  
  13. /* Are there any objects selected? If not, alert the user */
  14. if rc>0 then do
  15.     allocarexxrequester '"RotateAboutPoint Alert"' 368 59
  16.     reqhandle=result
  17.     addarexxgadget reqhandle EXIT 286 42 70 label "_Exit"
  18.         Exithandle=result
  19.     addarexxgadget reqhandle TEXT 8 10 352 border none string "'There are no objects selected. Select one'"
  20.     addarexxgadget reqhandle TEXT 8 20 352 border none string "'or more objects and choose the macro again.'"
  21.     doarexxrequester reqhandle
  22.     freearexxrequester reqhandle
  23.     EXIT
  24. end
  25.  
  26. /* if objects are locked, we don't want the actual lock requester opening */
  27. /* 2 or more times, so let's simulate it and temporarily reset the lock */
  28. /* status if required. */
  29. getobjectlock
  30. lockstatus=result
  31. ignorehandle=1
  32. lockaction=0
  33. if lockstatus='ON' | lockstatus='UNKNOWN' then do
  34.     allocarexxrequester '"Locked"' 254 55
  35.     reqhandle=result
  36.     addarexxgadget reqhandle EXIT 172 38 70 label "_Cancel"
  37.         cancelhandle=result
  38.     addarexxgadget reqhandle EXIT 12 38 70 label "_Ignore"
  39.         ignorehandle=result
  40.     addarexxgadget reqhandle EXIT 92 38 70 label "_Unlock"
  41.         unlockhandle=result
  42.     addarexxgadget reqhandle TEXT 8 10 232 border none string "'A selected object is locked.'"
  43.     doarexxrequester reqhandle
  44.     lockaction=result
  45.     freearexxrequester reqhandle
  46.  
  47.     /* If Cancel, then exit */
  48.     if lockaction=cancelhandle then do
  49.         exit
  50.     end
  51.     /* If Unlock, then unlock. If Ignore, temporarily unlock */
  52.     /* Note, this doesn't properly handle the situation of some objects being locked and others not. They'll all be locked at the end of this script. */
  53.     if lockaction=unlockhandle | lockaction=ignorehandle then unlock
  54. end
  55.  
  56. rstem.slant=left(rstem.slant,length(rstem.slant)-1)
  57. rstem.twist=left(rstem.twist,length(rstem.twist)-1)
  58. astem.x=left(astem.x,length(astem.x)-1)||'"'
  59. astem.y=left(astem.y,length(astem.y)-1)||'"'
  60.  
  61. /* PGS3 returns slant and twist. Reduce to rotate and remainder. */
  62. aslant=abs(rstem.slant)
  63. atwist=abs(rstem.twist)
  64. if rstem.slant=rstem.twist then do
  65.     rstem.rotate=rstem.slant||'°'
  66.     rstem.slant='0°'
  67.     rstem.twist='0°'
  68.     end
  69. else do
  70.     if aslant<atwist then do
  71.         rstem.rotate=rstem.slant||'°'
  72.         mult=rstem.slant*-1
  73.         end
  74.     else do
  75.         rstem.rotate=rstem.twist||'°'
  76.         mult=rstem.twist*-1
  77.     end
  78.     rstem.slant=rstem.slant+mult||'°'
  79.     rstem.twist=rstem.twist+mult||'°'
  80. end
  81.  
  82. /* Allocate requester */
  83. allocarexxrequester '"Rotate About Point"' 290 93
  84. reqhandle=result
  85.  
  86. /* Allocate a list for the about cycle */
  87. allocarexxlist
  88. aboutlist=result
  89. addarexxlist aboutlist 'Center'
  90. addarexxlist aboutlist 'Point'
  91.  
  92. /* Add gadgets */
  93. addarexxgadget reqhandle EXIT 12 76 70 label "_Ok"
  94.     Okhandle=result
  95. addarexxgadget reqhandle EXIT 210 76 70 label "_Cancel"
  96.     Cancelhandle=result
  97. addarexxgadget reqhandle TEXT 8 8 128 border none string "'Rotation Amount'"
  98. addarexxgadget reqhandle STRING 12 22 122 label "_Rotate" string rstem.rotate
  99.     rotatehandle=result
  100. addarexxgadget reqhandle STRING 20 36 114 label "_Slant" string rstem.slant
  101.     slanthandle=result
  102. addarexxgadget reqhandle STRING 20 50 114 label "_Twist" string rstem.twist
  103.     twisthandle=result
  104. addarexxgadget reqhandle TEXT 146 8 120 border none string "'Rotation Point'"
  105. addarexxgadget reqhandle CYCLE 150 22 130 label '"_About"' list aboutlist current 0
  106.     abouthandle=result
  107. if astem.mode='POINT' then do
  108.     setarexxgadget reqhandle abouthandle current 1
  109.     addarexxgadget reqhandle STRING 158 36 106 label "_Horz" string astem.x
  110.     horzhandle=result
  111.     addarexxgadget reqhandle STRING 158 50 106 label "_Vert" string astem.y
  112.     verthandle=result
  113.     end
  114. else do
  115.     setarexxgadget reqhandle abouthandle current 0
  116.     addarexxgadget reqhandle STRING 158 36 106 label "_Horz"
  117.     horzhandle=result
  118.     addarexxgadget reqhandle STRING 158 50 106 label "_Vert"
  119.     verthandle=result
  120. end
  121. /* Show requester */
  122. doarexxrequester reqhandle
  123. action=result
  124.  
  125. /* If Cancel, then exit */
  126. if action=CancelHandle then signal cancel
  127.  
  128. /* If Rotate, then rotate it and exit */
  129. /* Get gadget status */
  130. getarexxgadget reqhandle rotatehandle string
  131. rot=result
  132. if lastpos('°',rot)~=0 then rot=left(rot,lastpos('°',rot)-1)
  133. getarexxgadget reqhandle slanthandle string
  134. sla=result
  135. if lastpos('°',sla)~=0 then sla=left(sla,lastpos('°',sla)-1)
  136. getarexxgadget reqhandle twisthandle string
  137. twi=result
  138. if lastpos('°',twi)~=0 then twi=left(twi,lastpos('°',twi)-1)
  139. getarexxgadget reqhandle horzhandle string
  140. horz=result
  141. getarexxgadget reqhandle verthandle string
  142. vert=result
  143.  
  144. if rot="" then rot=0
  145. if sla="" then sla=0
  146. if twi="" then twi=0
  147. if horz="" then horz astem.horz
  148. if vert="" then vert astem.vert
  149.  
  150. /* Determine if the rotation point was changed from center, then set rotation point */
  151. if right(horz,1)='"' | right(horz,1)=i then horz=left(horz,length(horz)-1)
  152. if left(horz,1)='"' | left(horz,1)=i then vert=left(vert,length(vert)-1)
  153. astem.x=left(astem.x,length(astem.x)-1)
  154. astem.y=left(astem.y,length(astem.y)-1)
  155. refresh wait
  156.  
  157. getarexxgadget reqhandle abouthandle current
  158. if result=0 then do
  159.     editobject aboutcenter
  160.     end
  161. else do
  162.     editobject about horz vert
  163. end
  164.  
  165. sla=sla+rot
  166. twi=twi+rot
  167.  
  168. /* rotate the selected objects */
  169. editobject skew sla twi
  170. if lockaction=ignorehandle then lock
  171. refresh continue
  172.  
  173. /* clean up and exit */
  174. CANCEL:
  175. freearexxrequester reqhandle
  176. freearexxlist aboutlist
  177. exit
  178. return 0
  179.